package com.mapapp.flutter_mapapp.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mapapp.flutter_mapapp.R;
import com.mapapp.flutter_mapapp.persenter.OtherInfoPresenter;
import com.mapapp.flutter_mapapp.service.AudioRecordService;
import com.mapapp.flutter_mapapp.util.ToastUtils;
import com.mapapp.flutter_mapapp.view.OtherInfoViewInterface;
import com.mapapp.flutter_mapapp.widget.TitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OtherInfoActivity extends ImmersiveBaseActivity implements OtherInfoViewInterface {

    @BindView(R.id.et_info)
    EditText etInfo;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;
    @BindView(R.id.title_bar)
    TitleBar titleBar;

    private OtherInfoPresenter presenter;
    private String regionId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_other_info);
        ButterKnife.bind(this);
        presenter = new OtherInfoPresenter(this, this, lifecycleSubject);

        regionId = getIntent().getStringExtra("regionId");

        titleBar.getIvBack().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

    }

    @Override
    public void showResult(boolean isSuccess) {
        if (isSuccess) {
            finish();
        }
    }

    @OnClick(R.id.tv_submit)
    public void onViewClicked() {
        if (TextUtils.isEmpty(etInfo.getText().toString().trim())) {
            ToastUtils.showMessage(mContext, "请填写备注信息");
            return;
        }

        presenter.submitComment(regionId, etInfo.getText().toString(), AudioRecordService.audioName);
    }
}
